<?php

declare(strict_types=1);

namespace App\Model\Users;



use App\Model\Model;

/**
 * @property int $id 
 * @property int $uid 用户 uid
 * @property int $soft_id 主账号 uid
 * @property int $account_id 关联账册 id
 * @property int $type 消费类型，1：入账 ，2：出账
 * @property string $card_no 会员卡号
 * @property int $amount 消费金额
 * @property string $remark 备注信息
 * @property string $relation_info 关联其他信息
 * @property int $cate_id 消费类目 id
 * @property int $status 状态
 * @property \Carbon\Carbon $save_date 记账日期
 * @property \Carbon\Carbon $created_at 录入时间
 * @property \Carbon\Carbon $updated_at 更新时间
 */
class UsersAmountLog extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'users_amount_logs';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'uid', 'soft_id', 'account_id', 'type', 'card_no', 'amount', 'remark', 'relation_info', 'cate_id', 'status', 'save_date', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'uid' => 'integer', 'soft_id' => 'integer', 'account_id' => 'integer', 'type' => 'integer', 'amount' => 'integer', 'cate_id' => 'integer', 'status' => 'integer', 'save_date' => 'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime'];



    public function cate()
    {
        return $this->hasOne(UserCategory::class,'id','cate_id')->select(['id','name','icon','remark','industry_id']);
    }


    public function account()
    {
        return $this->hasOne(UsersAccount::class,'id','account_id')->select(['id','account_name','remark','type']);
    }


}
